package pl.edu.agh.mguesser.ui.game;

import java.awt.BorderLayout;
import javax.annotation.PostConstruct;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.springframework.stereotype.Controller;
import pl.edu.agh.mguesser.game.listener.GameStartedListener;
import pl.edu.agh.mguesser.game.listener.UserChangedListener;

/**
 * @author keiran
 */
@Controller
public class UserPanel extends JPanel implements GameStartedListener,
                                                 UserChangedListener {

    private JTextField currentUserField;
    
    @PostConstruct
    public void postConstruct() {
        setLayout(new BorderLayout());
        
        currentUserField = new JTextField();
        add(currentUserField, BorderLayout.CENTER);
    }

    @Override
    public void gameStarted() {
        currentUserField.setText("");
    }
    
    @Override
    public void newUser(String userName) {
        currentUserField.setText("USER: " + userName);
    }

}
